﻿
namespace Ctef.Web.Extensions
{
    public static class StringExtensions
    {
        // TODO: remove this extension after migration to .NET 4.0
        public static bool IsNullOrWhiteSpace(this string input)
        {
            return string.IsNullOrEmpty(input) ? true : input.Trim().Length == 0;
        }

        public static string TrimOrDefault(this string input, string defaultValue)
        {
            if (input.IsNullOrWhiteSpace())
            {
                return defaultValue;
            }

            return input.Trim();
        }

        public static string TrimOrEmpty(this string input)
        {
            return input.TrimOrDefault(string.Empty);
        }
    }
}